package com.yangtzeu.jwc.business;

import java.util.LinkedHashMap;
import java.util.Map;

import android.content.Context;

import com.loopj.android.http.AsyncHttpClient;
import com.yangtzeu.jwc.app.MyApplication;

public class BaseBusiness {
    protected MyApplication app;
    protected Map<String, String> addCustomParams;
    protected Map<String, String> paramsMap;
    protected HttpBusiness httpBusiness;
    protected Context context;

    // 数据库操作类
    public BaseBusiness(Context context) {
	this.context = context;
	this.app = MyApplication.getInstance();
	this.httpBusiness = new HttpBusiness(this.context);
	this.paramsMap = new LinkedHashMap<String, String>();
	// 初始化AbSqliteStorage
    }

    public AsyncHttpClient getNewClient() {
	return httpBusiness.getNewClient();
    }

    /**
     * 设置基本参数
     */
    protected BaseBusiness addCustomParams(String key, String value) {
	paramsMap.put(key, value);
	return this;
    }

    protected BaseBusiness removeParams(String key) {
	paramsMap.remove(key);
	return this;
    }

    protected BaseBusiness clearParams() {
	paramsMap.clear();
	return this;
    }

    protected Map<String, String> getParamsMap() {
	return paramsMap;
    }

    protected void doHttpRequest(String path, final MCallBack callBack) {
	httpBusiness.doHttpRequest(path, callBack);
    }

    protected void doHttpRequest(String path, Map<String, String> paramsMap2, final MCallBack callBack) {
	httpBusiness.doHttpRequest(path, paramsMap2, callBack);
    }
}
